package com.lc.hot100.lc21;

import com.lc.utils.ListNode;

public class Main {

}

class Solution {
    public ListNode mergeTwoLists(ListNode list1, ListNode list2) {
        ListNode head = new ListNode(0);
        ListNode t = head;
        while(list1 != null && list2 != null) {
        	
        	if (list1.val > list2.val) {
        		t.next = list2;
        		list2 = list2.next;
        	} else {
        		t.next = list1;
        		list1 = list1.next;
        	}
        	t = t.next;
        	
        }
        if (list1 == null) {
        	t.next = list2;
        } else {
        	t.next = list1;
        }
        return head.next;
    }
}
